package services.dingtalk

import com.typesafe.config.Config
import play.api.ConfigLoader

case class DingtalkConfig(company:String,url:String,AgentId:Int,AppKey:String,AppSecret:String,CorpId:String,appId:String,appSecret:String)
object DingtalkConfig {
  implicit val configLoader:ConfigLoader[DingtalkConfig] = new ConfigLoader[DingtalkConfig] {
    override def load(config: Config, path: String): DingtalkConfig = {
      val conf = if (path.isEmpty){
        config.getConfig("dingtalk.config.default")
      }else{
        config.getConfig("dingtalk.config."+path)
      }

      DingtalkConfig(
        company =conf.getString("company"),
        url =conf.getString("url"),
        AgentId = conf.getInt(("AgentId")),
        AppKey = conf.getString("AppKey"),
        AppSecret = conf.getString("AppSecret"),
        CorpId = conf.getString("CorpId"),
        appId = conf.getString("appId"),
        appSecret = conf.getString("appSecret")
      )
    }
  }

}
